#!/usr/bin/python

import csv
import os
import time

# our game replay fetch and parser module
# TODO(bmw) rename
import parser

GAME_LIST_PATH = os.path.join('..', '..', 'data', 'games.txt')


def main():
    gameReader = csv.reader(open(GAME_LIST_PATH))
    # one line, one list of gameid strings
    gameStr = []
    for item in gameReader:
        gameStr = item 
    #print gameStr
    game_list = [int(item) for item in gameStr]
    count = 0
    for gameid in game_list:
        count = count + 1
        #if count > 1:
        #    break
        print count
        #print gameid
        time.sleep(5)
        parser.parseSaveGame(gameid)
        #json_replay = parser.pullReplayData(gameid)
        #(winner, hills, state) = parser.decodeReplay(json_replay)


if __name__ == '__main__':
    main()
